const ContractService = require('./contracts');

class CallbackService {
  constructor() {
    this.contractService = new ContractService();
  }
 async handleContracts(data) {
    if (!data.FlowId) return
    const { Approvers, CcInfos, ...restData } = data
    console.log('===============', CcInfos)
    const finalData = {...restData, ApproverName:Approvers[0].ApproverName, ApproverMobile:Approvers[0].ApproverMobile}
    const find = await this.contractService.dbService.getById(data.FlowId);
    if(find){
      this.contractService.updateCallbackChangeStatus(data.FlowId, finalData)
    }else{
      this.contractService.create(finalData)
    }
   }
}

module.exports = CallbackService;